import jdk.internal.util.xml.impl.Input;

import java.io.*;
import java.util.Arrays;

public class 连号区间数 {
    static int N = 1010;
    static int[] arr = new int[N];
    static int[] cpy = new int[N];
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintStream out = new PrintStream(System.out);
        int n = Integer.parseInt(in.readLine());
        String[] str = in.readLine().split(" ");
           for (int i=1;i<=n;i++) {
               arr[i] = Integer.parseInt(str[i-1]);
               cpy[i] = arr[i];
           }

           int count = 0;
          for(int i=1;i<=n;i++) {
              int max = arr[i];
              int min = arr[i];
               for(int j=1;j<=n-i+1;j++) {
                   max = Math.max(max,arr[j]);
                   min = Math.min(min,arr[j]);
                   if(max-min==j-i) {
                       count++;
                       System.out.println(min+"  "+max);
                   }
               }
          }
           /*  超时了，要优化！！！！！*/

   /*     for(int i=1;i<=n;i++) {
            int max = arr[i];
            int min = arr[i];
            for (int j = i; j <=n ; j++) {
                max = Math.max(max,arr[j]);
                min = Math.min(min,arr[j]);
                if(max-min==j-i) count++;
            }
        }*/
        System.out.println(count);
    }
}
